package com.jade.journal;

import com.jade.journal.desc.AppenderDesc;
import com.jade.journal.desc.JournalDesc;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * 抽象的Appender
 *
 * @author sky
 * @version 1.0 14-9-22 下午1:04
 */
public abstract class AbstractAppender implements JournalAppender
{
    protected String name;
    protected String type;
    protected Log log;
    protected JournalDesc desc;
    protected AppenderDesc appenderDesc;

    protected AbstractAppender(String type, JournalDesc desc, AppenderDesc appenderDesc)
    {
        this.type = type;
        this.desc = desc;
        this.appenderDesc = appenderDesc;
        this.name = desc.getName();
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getType()
    {
        return type;
    }

    public JournalDesc getDesc()
    {
        return desc;
    }

    public AppenderDesc getAppenderDesc()
    {
        return appenderDesc;
    }

    public void init(JournalEvent event)
    {
        log = LogFactory.getLog("journal/appender/" + getType() + "_" + getName());
    }

    public void close()
    {
        //do nothing
    }

}
